package com.gxa.service.investment.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.investmentDto.IntentionRegisterQuitDto;
import com.gxa.dto.investmentDto.IntentionRegisterQuitResult;
import com.gxa.entity.commlife.BusinessManagement;
import com.gxa.entity.investment.IntentionRegister;
import com.gxa.mapper.investment.IntentionRegisterMapper;
import com.gxa.service.investment.IntentionRegisterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 意向登记表 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-17 03:52:28
 */
@Service
public class IntentionRegisterServiceImpl extends ServiceImpl<IntentionRegisterMapper, IntentionRegister> implements IntentionRegisterService {

    @Autowired
    private IntentionRegisterMapper intentionRegisterMapper;

    @Override
    public List<IntentionRegisterQuitResult> seletAll() {
        return intentionRegisterMapper.seletAll();
    }

    @Override
    public IntentionRegisterQuitResult quitById(Integer id) {
        return intentionRegisterMapper.quitById(id);
    }


    @Override
    public Map<String, Object> queryList(IntentionRegisterQuitDto intentionRegisterQuitDto, Integer pageNum, Integer pageSize) {
        Map<String,Object> map = new HashedMap();
        Page<IntentionRegisterQuitResult> page = PageHelper.startPage(pageNum,pageSize);
        List<IntentionRegisterQuitResult> intentionRegisterQuitResultList = this.intentionRegisterMapper.quit(intentionRegisterQuitDto);
        PageInfo<IntentionRegisterQuitResult> pageInfo = new PageInfo<>(intentionRegisterQuitResultList);
        map.put("pageInfo",pageInfo);
        return map;
    }


    @Override
    public void add(IntentionRegister intentionRegister) {
        intentionRegisterMapper.insert(intentionRegister);
    }
    @Override
    public void updateToState(Integer id, Integer state) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("id",id);
        updateWrapper.set("state", state);
        intentionRegisterMapper.update(null, updateWrapper);
    }


}
